package com.ninghushangbao.ninghu.service.Impl;

import com.ninghushangbao.ninghu.entity.Carousel;
import com.ninghushangbao.ninghu.mapper.CarouselMapper;
import com.ninghushangbao.ninghu.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    CarouselMapper carouselMapper;

    @Override
    public void addCarousel(Carousel carousel) {
        carousel.setCreateTime(new Date());
        carousel.setUpdateTime(new Date());
        carouselMapper.addCarousel(carousel);
    }

    @Override
    public List<Carousel> selectCarousel() {
        return carouselMapper.selectCarousel();
    }

    @Override
    public Carousel selectCarouselById(int id) {
        return carouselMapper.selectCarouselById(id);
    }

    @Override
    public void updateCarousel(Carousel carousel) {
        carousel.setUpdateTime(new Date());
        carouselMapper.updateCarousel(carousel);
    }

    @Override
    public void deleteCarouselById(List<Integer> carouselId) {
        carouselMapper.deleteCarouselById(carouselId);
    }
}
